package elsa.bootmapper;

import elsa.bean.ScsExp;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ExpMapper {

    //查询经验条数(所有)
    @Select("select count(*) from scs_exp")
    public int findExpCount();

    //查询经验列表(所有)
    @Select("select expnum, expname, exptxr, exptime from scs_exp order by exptime desc")
    public List<ScsExp> findAllExp();

    //查询经验条数(上传者  模糊查询)
    @Select("select count(*) from scs_exp where exptxr like CONCAT(CONCAT('%', #{exptxr}), '%')")
    public int findExpCountByExptxr(String exptxr);

    //查询经验列表(上传者  模糊查询)
    @Select("select expnum, expname, exptxr, exptime from scs_exp where exptxr like CONCAT(CONCAT('%', #{exptxr}), '%') order by exptime desc")
    public List<ScsExp> findAllExpByExptxr(String exptxr);

    //查询经验条数(经验名称  模糊查询)
    @Select("select count(*) from scs_exp where expname like CONCAT(CONCAT('%', #{expname}), '%')")
    public int findExpCountByExpname(String expname);

    //查询经验列表(经验名称  模糊查询)
    @Select("select expnum, expname, exptxr, exptime from scs_exp where expname like CONCAT(CONCAT('%', #{expname}), '%') order by exptime desc")
    public List<ScsExp> findAllExpByExpname(String expname);

    //查询经验信息
    @Select("select expnum, expname, expcontent, exptxr, exptime from scs_exp where expnum = #{expnum,jdbcType=INTEGER}")
    ScsExp findExpInfo(@Param("expnum") Integer expnum);

    //新建经验
    @Insert("insert into scs_exp (expname, expcontent, exptxr, exptime) values (#{expname,jdbcType=VARCHAR}, #{expcontent}, #{exptxr,jdbcType=VARCHAR}, #{exptime})")
    void saveExp(ScsExp scsExp);

    //更新经验
    @Update("update scs_exp set expname = #{expname,jdbcType=VARCHAR},expcontent = #{expcontent},exptxr = #{exptxr,jdbcType=VARCHAR},exptime = #{exptime} where expnum = #{expnum,jdbcType=INTEGER}")
    void updateExp(ScsExp scsExp);

    //删除经验
    @Delete("delete from scs_exp where expnum = #{expnum,jdbcType=INTEGER}")
    void deleteExp(@Param("expnum") Integer expnum);
}
